<?php
include ("config/koneksi.php");

$username = $_POST['username'];
$pass=$_POST['password'];
$level=$_POST['level'];

if($_POST['level']=='admin'){

	$login=mysql_query("SELECT * FROM user WHERE username='$username' AND password='$pass' AND level='$level'");
$ketemu=mysql_num_rows($login);
$r=mysql_fetch_array($login);
	if ($ketemu>0)
	{
		session_start();
		$_SESSION['username']=$r['username'];
		$_SESSION['password']=$r['password'];
		$_SESSION['level']=$r['level'];
		
	header('location:media_admin.php');	
	}
	else
	{
		echo"data tidak ditemukan";
		
		}
}elseif ($_POST['level']=='ketua'){
	$login=mysql_query("SELECT * FROM user WHERE username='$username' AND password='$pass' AND level='$level'");
$ketemu=mysql_num_rows($login);
$r=mysql_fetch_array($login);
	if ($ketemu>0)
	{
		session_start();
		$_SESSION['username']=$r['username'];
		$_SESSION['password']=$r['password'];
		$_SESSION['level']=$r['level'];
		
	header('location:media_ketua.php');	
	}
	else
	{
		echo"data tidak ditemukan";
		
		}

}
?>